package top.yxqz.ck.other;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mr.余
 * @date 2022/11/24
 * @package top.yxqz.ck.other
 */
@WebServlet("/other/demo6")
public class CookieDemo6 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie[] cookies = request.getCookies();
        System.out.println("这里是CookieDemo6");
        for (Cookie ck:cookies
             ) {
            if ("username".equals(ck.getName())){
                System.out.println("value:"+ck.getValue());
            }
        }
    }
}
